#include "RoleMgr.h"
#include "CRole.h"

using std::map;

IRole* CRoleMgr::QueryRole(unsigned int idRole)
{
	IRole* pRole = NULL;

	map<unsigned int, IRole*>::iterator itr = m_mapRole.find(idRole);
	if (itr != m_mapRole.end())
	{
		pRole = itr->second;
	}

	return pRole;
}

IRole* CRoleMgr::CreateNewRole(unsigned int idRole)
{
	IRole* pRole = new CRole(idRole);

	if (pRole != NULL)
	{
		m_mapRole[idRole] = pRole;
	}
	
	return pRole;
}

void CRoleMgr::OnTimer()
{
	map<unsigned int, IRole*>::iterator itr;

	for (itr = m_mapRole.begin(); itr != m_mapRole.end(); itr++)
	{
		itr->second->OnTimer();
	}
}